/*
 *
 * Copyright (c) 2023 - future
 * @author fzh
 * @email e_341877120_mail@163.com
 * @link https://mvnrepository.com/search?q=io.github.xrfzh.cn
 *
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

package cn.xrfzh.common.utils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class MailPatternMatchUtil {

	/**
	 * 验证输入的邮箱格式是否符合
	 * @param email 待校验格式的邮箱
	 * @return boolean
	 */
	public static boolean isMatchedOrNot(String email) {
		Pattern pattern = Pattern.compile("^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(.[a-zA-Z0-9_-]+)+$");
		boolean flag = false;
		if (null != email) {
			Matcher matcher = pattern.matcher(email);
			flag = matcher.matches();
		}
		return flag;
	}

	public static void main(String[] args) {
		boolean flag = isMatchedOrNot("e_341877120_mail@163.com");
		System.out.println(flag);
	}

}
